package com.saa.application.controller;


import com.saa.application.po.SaaApplicationDeploymentRequest;
import com.saa.application.service.AppDeploymentRequestService;
import com.saa.common.vo.OmsResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/appdeploymentrequest")
public class AppDeploymentRequestController {
    private Logger logger = LoggerFactory.getLogger(AppDeploymentRequestController.class);

    @Autowired
    private AppDeploymentRequestService appDeploymentRequestService;

    @PostMapping("/insertAppDeploymentRequest")
    public OmsResultVo insertAppDeploymentRequest(@RequestBody SaaApplicationDeploymentRequest saaApplicationDeploymentRequest) {
        try {
            return appDeploymentRequestService.insertAppDeploymentRequest(saaApplicationDeploymentRequest);
        } catch (Exception e) {
            return OmsResultVo.builder(500, "新增失败", null);
        }
    }

    @PostMapping("/getAppDeploymentRequestPage")
    public OmsResultVo getAppDeploymentRequestPage(@RequestBody SaaApplicationDeploymentRequest saaApplicationDeploymentRequest, Integer page, Integer pageSize) {
        try {
            return appDeploymentRequestService.getAppDeploymentRequestPage(saaApplicationDeploymentRequest, page, pageSize);
        } catch (Exception e) {
            return OmsResultVo.builder(500, "查询失败", null);
        }
    }

    @PostMapping("/getAppDeploymentRequest")
    public OmsResultVo getAppDeploymentRequest(@RequestBody SaaApplicationDeploymentRequest saaApplicationDeploymentRequest) {
        try {
            return appDeploymentRequestService.getAppDeploymentRequest(saaApplicationDeploymentRequest);
        } catch (Exception e) {
            return OmsResultVo.builder(500, "查询失败", null);
        }
    }

    @PostMapping("/updateAppDeploymentRequest")
    public OmsResultVo updateAppDeploymentRequest(@RequestBody SaaApplicationDeploymentRequest saaApplicationDeploymentRequest) {
        try {
            return appDeploymentRequestService.updateAppDeploymentRequest(saaApplicationDeploymentRequest);
        } catch (Exception e) {
            return OmsResultVo.builder(500, "更新失败", null);
        }
    }

    @PostMapping("/deleteAppDeploymentRequest")
    public OmsResultVo deleteAppDeploymentRequest(@RequestBody SaaApplicationDeploymentRequest saaApplicationDeploymentRequest) {
        try {
            return appDeploymentRequestService.deleteAppDeploymentRequest(saaApplicationDeploymentRequest);
        } catch (Exception e) {
            return OmsResultVo.builder(500, "删除失败", null);
        }
    }
}
